#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

string shortestBeautifulSubstring(string s, int k) {
    if (ranges::count(s, '1') < k) {
        return "";
    }

    auto res = s;
    int cnt = 0, l = 0;

    for (int r = 0; r < s.size(); r++)
    {
        cnt += s[r] - '0';
        while (cnt > k || s[l] == '0')
            cnt -= s[l++] - '0';
        if (cnt == k)
        {
            auto t = s.substr(l, r - l + 1);
            if (t.size() < res.size() || t.size() == res.size() && t < res)
                res = move(t);
        }
    }
    return res;
}